package com.event.system.service.impl;

import com.event.system.domain.SysEventOrder;
import com.event.system.mapper.SysEventOrderMapper;
import com.event.system.mapper.SysEventRegionMapper;
import com.event.system.service.ISysEventOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class SysEventOrderServiceImpl implements ISysEventOrderService {

    @Autowired
    private SysEventOrderMapper mapper;

    @Autowired
    private SysEventRegionMapper sysEventRegionMapper;

    @Override
    public List<SysEventOrder> selectSysEventOrderList(SysEventOrder sysEventOrder) {
        return mapper.selectSysEventOrderList(sysEventOrder);
    }

    @Override
    public SysEventOrder selectSysEventOrderByOrderId(Long orderId) {
        return mapper.selectSysEventOrderByOrderId(orderId);
    }

    @Override
    @Transactional
    public int add(SysEventOrder sysEventOrder) {
        Long regionId = sysEventOrder.getRegionId();
        sysEventRegionMapper.updateByRegionIdToOne(regionId);
        return mapper.add(sysEventOrder);
    }

    @Override
    public int update(SysEventOrder sysEventOrder) {
        return 0;
    }

    @Override
    public int deleteSysEventOrderByOrderId(Long[] rosterId) {
        return 0;
    }

    /**
     * 根据orderId修改状态为1
     *
     * @param sysEventOrder
     * @return
     */
    @Override
    public int updateByOrderIdToOne(SysEventOrder sysEventOrder) {
        return mapper.updateByOrderIdToOne(sysEventOrder);
    }

    /**
     * 根据orderId修改状态为2
     *
     * @param sysEventOrder
     * @return
     */
    @Override
    public int updateByOrderIdToTwo(SysEventOrder sysEventOrder) {
        return mapper.updateByOrderIdToTwo(sysEventOrder);
    }

    /**
     * 根据orderId修改状态为3
     *
     * @param sysEventOrder
     * @return
     */
    @Override
    public int updateByOrderIdToThree(SysEventOrder sysEventOrder) {
        return mapper.updateByOrderIdToThree(sysEventOrder);
    }
}
